<script setup>
import { ref, getCurrentInstance } from "vue";
import { ElMessage, ElMessageBox } from "element-plus";
import { listRecruitService } from "@/api/Recruit.js";

// 数据模型
const recruits = ref([]);
const recruitData = ref({
  title: "",
  content: "",
  image: "",
  requirement: "",
});

//分页条数据模型
const pageNum = ref(1); //当前页
const total = ref(0); //总条数
const pageSize = ref(10); //每页条数

//----------------获取招募列表数据------------------
const getRecruits = async () => {
  let params = {
    pageNum: pageNum.value,
    pageSize: pageSize.value,
    categoryId: 3,
    approvalStatus: 2,
  };
  let result = await listRecruitService(params);
  recruits.value = result.data.items;
};
getRecruits();
</script>

<!-- ================================================================================================== -->
<!-- **************************************************************************************************** -->
<!-- ================================================================================================== -->

<template>
  <div class="block text-center" m="t-4">
    <el-carousel trigger="click" height="400px">
      <el-carousel-item v-for="item in recruits" :key="item.id">
        <h3 class="small justify-center" text="2xl">{{ item.title }}</h3>
        <div v-html="item.content"></div>
        <img :src="item.image" alt="招募图片" />
        <p>要求：{{ item.requirement }}</p>
      </el-carousel-item>
    </el-carousel>
  </div>
</template>

<!-- ================================================================================================== -->
<!-- **************************************************************************************************** -->
<!-- ================================================================================================== -->

<style scoped>
.demonstration {
  color: var(--el-text-color-secondary);
}

.el-carousel__item h3 {
  color: #475669;
  opacity: 0.75;
  line-height: 150px;
  margin: 0;
  text-align: center;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}
</style>
